<?php

/**
 * PageController is the default controller for this application
 */
class PageController extends CustomControllerBase {
	/**
	 * Constructor of index
	 */
	public function __construct() {
		parent::__construct ();
	}
	
	/**
	 * The "index" action is the default action for all controllers -- the
	 * landing page of the site.
	 *
	 * @return void
	 *
	 */
	public function indexAction() {
		$id = $this->getQuery ( 'id' );
		$id = intval ( $id );
		$pageEntity = $this->userPageDataService->getById ( $id );
		if (empty ( $pageEntity )) {
			// Go on to login page
			//$url = Zend_Registry::get('config')->APPLICATION_URL;
			$url = $this->getApplicationUrl ();
			CommonUtils::redirect ( $url );
			return - 1;
		}
		
		$pageEntity->content = htmlspecialchars_decode ( $pageEntity->content, ENT_QUOTES );
		
		//Update MetaInformation
		$this->setMetaDescription ( $pageEntity->metaDescription );
		$this->setPageTitle ( $pageEntity->headTitle );
		$this->setMetaKeywords ( $pageEntity->metaKeywords );
		$this->setPageName ( 'dynamic_page' );
		$this->smarty->assign ( 'pageEntity', $pageEntity );
		if ($this->isMobileMode == false) {
			// Assign Smarty Content
			$this->assignSmartyContent ( 'Index/dynamic_page.tpl' );
		} else {
			$this->assignSmartyMobileContent ( 'Index/m_dynamic_page.tpl' );
		}
	
		//$this->smarty->assign('SMARTY_CONTENT_PATH', 'template1/Index/dynamic_page.tpl');
	//$this->smarty->display(APPLICATION_PATH . '/Layouts/template1/MainLayout.tpl');
	}
}
